home *** CD-ROM | disk | FTP | other *** search
-
- // Copyright (C) 2002 by Luigi Pino. All Rights Reserved.
-
- /***************************************************************************/
-
- #include "../library/neurosis.h"
- #include "draw.h"
- #include "file_io.h"
- #include "hiscore.h"
- #include "initialize.h"
- #include "main.h"
- #include "menu_misc.h"
- #include "paddle.h"
- #include "sphere.h"
- #include "update.h"
-
- /***************************************************************************/
-
- Camera_Class camera;
- High_Score_Struct high_score_sphere;
- High_Score_Struct high_score_time;
- Light_Values_Struct light_values;
- Main_Menu_Class menu;
- Mouse_Class mouse;
- Object3_Class ground_cover;
- Object3_Class paddle[4];
- Object3_Class sphere[4];
- Object4_Class ground;
- Object4_Class wall_net;
- Object4_Class wall_side;
- Paddle_Struct paddle_object[4];
- Shadow_Box_Struct light_source;
- Sphere_Control_Struct sphere_object[4];
- Sub_Menu_Class menu_main;
- Sub_Menu_Class menu_options;
- Sub_Menu_Class menu_control;
- Sub_Menu_Class menu_high_scores;
- Sub_Menu_Class game_paused;
- Sub_Menu_Class game_scores;
- Timing_Class timing;
- Values_Struct values;
- Window_Class window(Texture_Total);
-
- bool connected[8]; // Keyboard 1,2 - Joystick 1,2,3,4, Computer, No User
- char high_score_name[16];
- float3 wall_pts[50];
- int goal_by_team = -1;
-
- /***************************************************************************/
-
- int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
-
- {
- if (Initialize_Objects() == false)
- {
- MessageBox(NULL, "Error In Memory Management.", "ERROR", MB_OK | MB_ICONEXCLAMATION);
- window.KillGLWindow();
- exit(1);
- }
-
- Initialize_System();
- Initialize_Menu();
- Load_Config_File();
-
- // if (!window.CreateGLWindow("Spherical Vengeance", 640, 480, 16, false))
- if (!window.CreateGLWindow("Spherical Vengeance", window.screen_width, window.screen_height, 16, true))
- exit(1);
-
- Initialize_Textures(false);
- timing.Update();
-
- while (window.quit_game == false)
- {
- timing.Update();
- window.Process_Messages();
-
- if (window.active)
- {
- glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
-
- if (values.game_position == Game_Intro)
- {
- window.Font_Begin();
- Intro();
- window.Font_End();
- }
- else if (values.game_position == Game_Menu)
- {
- window.Font_Begin();
- Menu();
- window.Font_End();
- }
- else if (values.game_position == Game_Play)
- Game();
- else if (values.game_position == Game_Ending)
- {
- window.Font_Begin();
- Ending();
- window.Font_End();
- }
-
- SwapBuffers(window.hDC);
- }
- }
-
- // Shutdown
- window.KillGLWindow();
- return (window.msg.wParam);
- }
-
- /***************************************************************************/
-
- void Game()
-
- {
- int x1;
-
- Update_Mouse();
- camera.Update(&timing);
-
- if (window.keys[VK_F1])
- {
- camera.axis_destination.x = 359.0f;
- camera.axis_destination.z = 0.0f;
- camera.zoom_destination = -500.0f;
- }
- else if (window.keys[VK_F2])
- {
- camera.axis_destination.x = 320.0f;
- camera.axis_destination.z = 0.0f;
- camera.zoom_destination = -500.0f;
- }
-
- if (paddle_object[Up].input.user == Computer)
- Paddle_AI(Up);
- else if (paddle_object[Up].input.user != No_User)
- Paddle_User_Input(Up);
-
- if (paddle_object[Down].input.user == Computer)
- Paddle_AI(Down);
- else if (paddle_object[Down].input.user != No_User)
- Paddle_User_Input(Down);
-
- if (paddle_object[Left].input.user == Computer)
- Paddle_AI(Left);
- else if (paddle_object[Left].input.user != No_User)
- Paddle_User_Input(Left);
-
- if (paddle_object[Right].input.user == Computer)
- Paddle_AI(Right);
- else if (paddle_object[Right].input.user != No_User)
- Paddle_User_Input(Right);
-
- Update_Nets();
-
- for (x1=0;x1<values.sphere_number;x1=x1+1)
- {
- Next_Position_Sphere(x1);
- Goal_Scored(x1);
- }
-
- Draw_Items();
-
- // Draw time left
- window.Font_Begin();
- if (values.game_type != Countdown)
- {
- if (values.seconds_left > 0)
- {
- window.Font_Time(false, true, true, false, values.seconds_left, -310.0f, 220.0f, 30.0f, R_5, G_5, B_5);
- values.seconds_left = values.seconds_left - timing.Get_Scale();
- }
- }
-
- if ((values.game_type == Timed) && (values.seconds_left <= 0))
- {
- int count = 0;
- float low_score = 10000.0f;
-
- // Get lowest score
- for (x1=Up;x1<=Right;x1=x1+1)
- {
- if ((paddle_object[x1].game_over == false) && (paddle_object[x1].score < low_score))
- low_score = paddle_object[x1].score;
- }
-
- for (x1=Up;x1<=Right;x1=x1+1)
- {
- if ((paddle_object[x1].game_over == false) && (paddle_object[x1].score > low_score))
- paddle_object[x1].game_over = true;
- }
-
- for (x1=Up;x1<=Right;x1=x1+1)
- {
- if (paddle_object[x1].game_over == false)
- count = count + 1;
- }
-
- if (count > 1)
- window.Font_Char("DONT LET THE NEXT ONE IN ...", -280.0f, 220.0f, 20.0f, R_5, G_5, B_5);
- else
- values.game_end_fade = true;
- }
- else if (values.game_type == Countdown)
- {
- int count = 0;
-
- for (x1=Up;x1<=Right;x1=x1+1)
- {
- if ((paddle_object[x1].game_over == false) && (paddle_object[x1].score < 0.0f))
- {
- paddle_object[x1].score = 0.0f;
- paddle_object[x1].game_over = true;
- }
- }
-
- for (x1=Up;x1<=Right;x1=x1+1)
- {
- if (paddle_object[x1].game_over == false)
- count = count + 1;
- }
-
- if (count <= 1)
- values.game_end_fade = true;
- }
- else if (values.game_type == High_Score)
- {
- if (values.seconds_left > 0)
- {
- window.Font_Char("SECONDS SINCE LAST GOAL:", -100.0f, 220.0f, 10.0f, R_9, G_9, B_9);
- window.Font_Float(paddle_object[Down].time_lapse, 2, 125.0f, 220.0f, 10.0f, R_9, G_9, B_9);
- window.Font_Char("MOST TIME WITH NO GOAL THIS GAME:", -100.0f, 205.0f, 10.0f, R_9, G_9, B_9);
- window.Font_Float(paddle_object[Down].time_lapse_score, 2, 125.0f, 205.0f, 10.0f, R_9, G_9, B_9);
- }
-
- if (values.seconds_left <= 0.0f)
- values.game_end_fade = true;
- }
-
- window.Font_End();
-
- if ((window.keys[VK_ESCAPE]) && (values.game_end_fade == false))
- {
- menu.Set_Current(&game_paused);
- values.game_position = Game_Menu;
- }
- }
-
- /***************************************************************************/